package com.example.sonone.funinterfacetest;

import org.springframework.lang.Nullable;

import java.util.concurrent.TimeUnit;

/* ━━━━━━佛祖保佑━━━━━━
 *                  ,;,,;
 *                ,;;'(    社
 *      __      ,;;' ' \   会
 *   /'  '\'~~'~' \ /'\.)  主
 * ,;(      )    /  |.     义
 *,;' \    /-.,,(   ) \    码
 *     ) /       ) / )|    农
 *     ||        ||  \)
 *     (_\       (_\
 * ━━━━━━永无BUG━━━━━━
 * @author ：zjq
 * @date ：2022/5/18 0:41
 * @description: TODO
 * @version: V1.0
 * @slogan: 天下风云出我辈，一入代码岁月催
 */
public class Test {


    public static void main(String[] args) throws InterruptedException {


        TimeUnit.SECONDS.sleep(1);
        AA.SECONDS.sleep(1);



        ConfirmCallback c1 = new ConfirmCallback() {
            @Override
            public void confirm(String a) {
                for (int i = 0; i < 10; i++) {
                    System.out.println("c1: " + a + " " + i);
                }

            }
        };
        c1.confirm("a");
        System.out.println("===================");

        ConfirmCallback c2 = a -> {
            for (int i = 0; i < 10; i++) {
                System.out.println("c2:" + a + " " + i);
            }
        };
        c2.confirm("c");

        System.out.println("===================");
        Test t = new Test();
        t.te();

        System.out.println("===================");

        new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println("r1: "+i);
                }
            }
        }.run();

        ((Runnable) () -> {
            for (int i = 10; i < 20; i++) {
                System.out.println("r2: "+i);
            }
        }).run();


    }

    public void te() {
        ConfirmCallback c2 = this::handle;
        //通俗的说，你可以将整个 Lambda 表达式作为接口的实现类
        c2.confirm("b");
    }

    public void handle(@Nullable String a) {
        System.out.println("handle:" + a);
    }


}
